<%--
  Created by IntelliJ IDEA.
  User: kadsg
  Date: 2023/1/5
  Time: 21:53
  To change this template use File | Settings | File Templates.
--%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>预约记录</title>
</head>
<body>
<jsp:include page="../../head/reader.jsp"/>
<div class="accordion accordion-flush" id="accordionFlushExample">

    <div class="accordion-item">
        <h2 class="accordion-header unUsed">
            <button class="accordion-button collapsed" type="button" data-bs-toggle="collapse"
                    data-bs-target="#unUsed" aria-expanded="false" aria-controls="unUsed">
                当前预约
            </button>
        </h2>
        <div id="unUsed" class="accordion-collapse collapse" aria-labelledby="unUsed"
             data-bs-parent="#accordionFlushExample">
            <div class="accordion-body">
                <c:if test="${unUsedRecord == null}">
                    当前没有预约！
                </c:if>
                <c:if test="${unUsedRecord != null}">
                    <table class="table table-hover">
                        <tbody>
                        <tr>
                            <th>楼层名</th>
                            <th>座位号</th>
                            <th>预约时间</th>
                        </tr>
                        <tr>
                            <td>${unUsedRecord.floor_name}</td>
                            <td>${unUsedRecord.number}</td>
                            <td>${unUsedRecord.reserve_time}</td>
                            <td>
                                <a href="${pageContext.request.contextPath}/StartServlet?floorName=${unUsedRecord.floor_name}&number=${unUsedRecord.number}&reserveTime=${unUsedRecord.reserve_time}"
                                   class="btn btn-primary">签到</a></td>
                            <td>
                                <a href="${pageContext.request.contextPath}/CancelServlet?floorName=${unUsedRecord.floor_name}&number=${unUsedRecord.number}&reserveTime=${unUsedRecord.reserve_time}"
                                   class="btn btn-danger">取消</a></td>
                        </tr>
                        </tbody>
                    </table>
                </c:if>
            </div>
        </div>
    </div>

    <div class="accordion-item">
        <h2 class="accordion-header in-use">
            <button class="accordion-button collapsed" type="button" data-bs-toggle="collapse"
                    data-bs-target="#in-use" aria-expanded="false" aria-controls="in-use">
                正在使用
            </button>
        </h2>
        <div id="in-use" class="accordion-collapse collapse" aria-labelledby="in-use"
             data-bs-parent="#accordionFlushExample">
            <div class="accordion-body">
                <c:if test="${inUseRecord == null}">
                    没有正在使用的座位！
                </c:if>
                <c:if test="${inUseRecord != null}">
                    <table class="table table-hover">
                        <tbody>
                        <tr>
                            <th>楼层名</th>
                            <th>座位号</th>
                            <th>预约时间</th>
                            <th>开始时间</th>
                        </tr>
                        <tr>
                            <td>${inUseRecord.floor_name}</td>
                            <td>${inUseRecord.number}</td>
                            <td>${inUseRecord.reserve_time}</td>
                            <td>${inUseRecord.start_time}</td>
                            <td><a href="${pageContext.request.contextPath}/EndServlet?floorName=${inUseRecord.floor_name}&number=${inUseRecord.number}&reserveTime=${inUseRecord.reserve_time}" class="btn btn-danger">签退</a></td>
                        </tr>
                        </tbody>
                    </table>
                </c:if>
            </div>
        </div>
    </div>

    <div class="accordion-item">
        <h2 class="accordion-header completed">
            <button class="accordion-button collapsed" type="button" data-bs-toggle="collapse"
                    data-bs-target="#completed" aria-expanded="false" aria-controls="completed">
                过往记录
            </button>
        </h2>
        <div id="completed" class="accordion-collapse collapse" aria-labelledby="completed"
             data-bs-parent="#accordionFlushExample">
            <div class="accordion-body">
                <c:if test="${completedRecords == null}">
                    暂无记录！
                </c:if>
                <c:if test="${completedRecords != null}">
                    <table class="table table-hover">
                        <tbody>
                        <tr>
                            <th>楼层名</th>
                            <th>座位号</th>
                            <th>预约时间</th>
                            <th>开始时间</th>
                            <th>结束时间</th>
                            <th>状态</th>
                        </tr>
                        <c:forEach items="${completedRecords}" var="record">
                            <tr>
                                <td>${record.floor_name}</td>
                                <td>${record.number}</td>
                                <td>${record.reserve_time}</td>
                                <c:if test="${record.cancel_flag == false}">
                                    <td>${record.start_time}</td>
                                    <td>${record.end_time}</td>
                                    <td>已结束</td>
                                </c:if>
                                <c:if test="${record.cancel_flag == true}">
                                    <td>-</td>
                                    <td>-</td>
                                    <td>读者取消</td>
                                </c:if>
                            </tr>
                        </c:forEach>
                        </tbody>
                    </table>
                </c:if>
            </div>
        </div>
    </div>

</div>
</body>
</html>
